package desbloqueiaTabela;

import hibernateutil.hibernateUtil;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class DesbloqueiaTabela {

	public void bloqueia(int state) {

		final byte sqlState = (byte) state;

		
		
		
		Session session = hibernateUtil.getSessionFactory().openSession();
		
		try {
		
		Transaction tx = null;
		tx = session.getTransaction();
		tx.begin();

		Query query = session.createSQLQuery("SET FOREIGN_KEY_CHECKS= "
				+ sqlState + "");
		query.executeUpdate();
		
		
		tx.commit();

		 } catch (RuntimeException e) {
		        e.printStackTrace();
		    } finally {
		        session.flush();
		        session.close();
		    }

	}
}
